var TurndownService = require('turndown')
var fs = require('fs')
const { turndown } = require('markdown-read')


var turndownService = new TurndownService()
var md = turndownService.turndown('<h1>Hello world!</h1>')
console.log(md);


// fs.readFile('html/mjj4.html', 'utf8' , (err, data) => {
//   if (err) {
//     console.error(err)
//     return
//   }
//   //console.log(data)
//   var md = turndownService.turndown(data)
// console.log(md);
// })

fs.readFile('html/mjj4.html', 'utf8' , (err, data) => {
  if (err) {
    console.error(err)
    return
  }

  // // read markdown from url
  // markdown('https://www.example.com')

  // // read readbility content from url
  // readability('https://shanyue.tech')

  // read markdown from html
  let md = turndown(data)

  md = md.replace(/\d{1,2}\s{2,10}/g, "");

  console.log(md);
  fs.writeFile("1.md", md, { encoding: 'utf-8' }, err => {
    err && reject(err)
    console.log('===write html file success')
  })
})





